<template>
	<view class="">
		<view class=" flexcenter" v-if="type==1">
			<u-tabs :list="list1" lineColor="#C01933" @click="changetab" :activeStyle="{
				    color: '#C01933',
				    fontWeight: 'bold',
				    transform: 'scale(1.05)'
				}" :inactiveStyle="{
				            color: '#333333',
							fontWeight: 'bold',
				            transform: 'scale(1)'
				        }" itemStyle="padding-left: 40px; padding-right: 40px; height: 44px;"></u-tabs>
		</view>
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;"></view>
		</view>
		<view class="mainpadding xiahuaxian margin_top flexbetween" v-if="type==1" v-for="item in list.data" :key="item.id" @click="ckmx()">
			<view class="">
				<view class="strongtext xiaohei">{{item.memo}}</view>
				<view class="ershiba xiaohui margin_top">{{item.createtime_text}}</view>
			</view>
			<view class="flexright">
				<view class="flexright">
					<!-- <view class="strongtext xiaohei">-</view> -->
					<!-- <view class="strongtext xiaohei">+</view> -->
					<view class="sanshier xiaohei fonweight">{{item.money}}</view>
				</view>
				<!-- <u-icon name="arrow-right" color="#999999" size="16"></u-icon> -->

			</view>
		</view>
		<view class="mainpadding xiahuaxian margin_top flexbetween" v-if="type==2" v-for="item in list.data" :key="item.id" @click="ckmx()">
			<view class="">
				<view class="strongtext xiaohei">{{item.out_biz_no}}</view>
				<view class="ershiba xiaohui margin_top">{{httpRequest.timereturn(item.createtime * 1000)}}</view>
			</view>
			<view class="flexright">
				<view class="flexright">
					<!-- <view class="strongtext xiaohei">-</view> -->
					<!-- <view class="strongtext xiaohei">+</view> -->
					<view class="sanshier xiaohei fonweight">{{item.price}}</view>
				</view>
				<!-- <u-icon name="arrow-right" color="#999999" size="16"></u-icon> -->
		
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				httpRequest,
				current: 0,
				list1: [{
						name: '全部',
						value: "0",
					},
					{
						name: '收入',
						value: 1,
					},
					{
						name: '支出',
						value: 2,
					}
				],
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				type:1,//1储值明细，2提现明细
			}
		},
		onLoad(options) {
			this.type = options.type
			if(this.type==1){
				uni.setNavigationBarTitle({
					title:"储值明细"
				})
			}else{
				uni.setNavigationBarTitle({
					title:"提现明细"
				})
			}
		},
		onShow() {
			this.init()
		},
		methods: {
			init(isPage, page) { //提现记录
				let _this = this;
				let url = '/api/user/getUserMoneyLog'
				
				let data = {
					page: page || 1,
					limit: _this.limit,
					type:this.current
				}
				if(this.type==2){
					url = '/api/user/getWithdrawalList'
					delete data.type
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// 查看明细
			ckmx() {
				uni.navigateTo({
					url: '/pages_mine/zhangdanmx'
				})
			},
			changetab(e) {
				this.current = e.value
				this.init()
				console.log(e, 999)
			},
		}
	}
</script>

<style>

</style>